package com.service.acl.service.impl;

import com.service.acl.pojo.UserRole;
import com.service.acl.mapper.UserRoleMapper;
import com.service.acl.service.UserRoleService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author testjava
 * @since 2020-10-22
 */
@Service
public class UserRoleServiceImpl extends ServiceImpl<UserRoleMapper, UserRole> implements UserRoleService {

    @Override
    public void saveUser(String userId, List<String> roleIds) {
        for (String roleId : roleIds) {
            UserRole userRole = new UserRole();
            userRole.setGmtCreate(new Date());
            userRole.setGmtModified(new Date());
            userRole.setRoleId(roleId);
            userRole.setUserId(userId);
            this.save(userRole);
        }
    }
}
